package com.zscat.mallplus.dms.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zscat.mallplus.core.LockInfo;
import com.zscat.mallplus.dms.service.IDeviceService;
import com.zscat.mallplus.qsg.QsgDevice;
import com.zscat.mallplus.utils.HttpClientUtil;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class LockTokenTask extends QuartzJobBean {
    @Autowired
    private IDeviceService deviceService;

    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
//        Map<String,String> params = new HashMap<>();
//        params.put("appKey", LockInfo.APPKEY);
//        params.put("appSecret",LockInfo.APPSECRET);
//        HttpClientUtil clientUtil = HttpClientUtil.getInstance();
//        String i = clientUtil.httpPost(LockInfo.GET_TOKEN,params);
//        JSONObject jsonObject = JSONObject.parseObject(i);
//        String token = jsonObject.getJSONObject("data").getString("token");
//        QueryWrapper qw = new QueryWrapper();
//        qw.eq("device_type",2);
//        List<QsgDevice> devices = deviceService.list(qw);
//        if (devices.size()>0){
//            for (QsgDevice device : devices){
//                device.setToken(token);
//                deviceService.updateById(device);
//            }
//        }
    }
}
